import java.util.Scanner;
public class nun_in_nums {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int x = sc.nextInt();
            int count = 0;
            for (int i = 1; i <= n; i++) {
                int b = i;
                while (b!=0){
                    int c = b%10;
                    b = b/10;
                    if(c==x){
                        count++;
                    }
                }

            }
            System.out.println(count);
        }
    }

